package ru.amse.tsyganov.jumleditor.main;

import ru.amse.tsyganov.jumleditor.model.ActionState;
import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.Transition;
import ru.amse.tsyganov.jumleditor.view.ActionStateView;
import ru.amse.tsyganov.jumleditor.view.ActivityGraphView;
import ru.amse.tsyganov.jumleditor.view.TransitionView;

public class Main {

	public static void main(String[] args) {
		ActivityGraphView<ActivityGraph> graph = createStatesModel();
		new Editor(graph);
	}

	private static ActivityGraphView<ActivityGraph> createStatesModel() {
		
		// creating model
		ActivityGraph activityGraph = new ActivityGraph();
		
		ActionState actionState1 = new ActionState();
		ActionState actionState2 = new ActionState();
		ActionState actionState3 = new ActionState();
		
		activityGraph.addState(actionState1);
		activityGraph.addState(actionState2);
		activityGraph.addState(actionState3);
		
		Transition transition1 = new Transition(
				actionState1.getStateVertex(),
				actionState2.getStateVertex());
		
		transition1.addBindings();
		
		Transition transition2 = new Transition(
				actionState2.getStateVertex(),
				actionState3.getStateVertex()); 
		
		transition2.addBindings();
		
		// creating representation
		ActivityGraphView<ActivityGraph> activityGraphView = 
			new ActivityGraphView<ActivityGraph>(activityGraph);
				
		ActionStateView<ActionState> actionStateView1 = 
			new ActionStateView<ActionState>(actionState1, activityGraphView);
		
		ActionStateView<ActionState> actionStateView2 = 
			new ActionStateView<ActionState>(actionState2, activityGraphView);
		
		ActionStateView<ActionState> actionStateView3 = 
			new ActionStateView<ActionState>(actionState3, activityGraphView);
		
		TransitionView<Transition> transitionView1 = 
			new TransitionView<Transition>(transition1, activityGraphView);
		
		TransitionView<Transition> transitionView2 = 
			new TransitionView<Transition>(transition2, activityGraphView);
		
		activityGraphView.getModelViewMap().getStatesMap().put(actionState1, actionStateView1);
		activityGraphView.getModelViewMap().getStatesMap().put(actionState2, actionStateView2);
		activityGraphView.getModelViewMap().getStatesMap().put(actionState3, actionStateView3);
		
		activityGraphView.getModelViewMap().getTransitionsMap().put(transition1, transitionView1);
		activityGraphView.getModelViewMap().getTransitionsMap().put(transition2, transitionView2);
		
		actionStateView1.setX(10);
		actionStateView1.setY(100);
		
		actionStateView2.setX(200);
		actionStateView2.setY(10);
		
		actionStateView3.setX(310);
		actionStateView3.setY(200);
		
		return activityGraphView;
	}
}
